package com.szholly.pro.watergas_server.ps.controller;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.szholly.pro.watergas_server.common.util.JsonUtil;
import com.szholly.pro.watergas_server.common.web.BaseController;
import com.szholly.pro.watergas_server.common.web.RequestUnit;
import com.szholly.pro.watergas_server.ps.service.SafeRoleService;
import com.szholly.data.general.RowBase;

@Controller
@RequestMapping("/SafeRoleInfo/*")
public class SafeRoleInfoController extends BaseController {

	@Autowired
	SafeRoleService safeRoleService;	
	
	/**
	 * 保存角色站点信息
	 * @throws Exception 
	 */
	@RequestMapping(value = "/saveRoleStation")
	public void saveRoleStation(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String roleId = RequestUnit.getParameter("roleId");
		String stationCodesStr = RequestUnit.getParameter("stationCodes");
		String[] stationCodes = stationCodesStr.split(",");
		safeRoleService.saveRoleStation(roleId, stationCodes);
	}
	
	/**
	 * 获取角色站点信息
	 * @throws Exception 
	 */
	@RequestMapping(value = "/getRoleStation")
	public void getRoleStation(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String roleId = RequestUnit.getParameter("roleId");
		String waterType = RequestUnit.getParameter("WATER_TYPE");
		List<RowBase> list = safeRoleService.getRoleStationList(roleId,waterType);
		String result = JsonUtil.ConvertArrayToJson(list);
		outString(result);
	}
	
}
